class VarA {
    int i;
}

class VarB {
    int i;

    public boolean equals(Object o) {
        VarB rval = (VarB) o;
        return rval.i == i;
    }
}

public class EqualsMethod {
    public static void main(String[] args) {
        VarA a1 = new VarA();
        VarA a2 = new VarA();
        a1.i = a2.i = 100;
        System.out.println(a1.equals(a2));  // false

        VarB b1 = new VarB();
        VarB b2 = new VarB();
        b1.i = b2.i = 100;
        System.out.println(b1.equals(b2)); // true
    }
}
